import java.util.Scanner;

/**
 * 4. 九进制转十进制
 * https://www.lanqiao.cn/problems/2095/learning/?page=1&first_category_id=1&second_category_id=3&tag_relation=intersection&tags=%E7%9C%81%E8%B5%9B,2022&sort=pass_rate&asc=0
 */
public class Main4 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int x = 2022;
        int sum = 0;
        int n = 0;
        while(x > 0) {
            int tmp = (int) ((x % 10) * Math.pow(9,n++));
            sum += tmp;
            x /= 10;
        }
        System.out.println(sum);
        scan.close();
    }
}
